<template>
  <el-container class="HomeContainer">
    <!-- 头部区域 -->
    <el-header>
      <div>
        <img style="width: 70px; height: 60px" src='../assets/logo.png' />
        <span>后台管理系统</span>
      </div>
      <router-link to='/login'>
        <el-button type="primary" round>登陆/注册</el-button>
      </router-link>
    </el-header>
    <el-container>
      <!-- 侧边栏 -->
      <el-aside :width="isCollapse ? '66px' : '200px' ">
        <div class="isCollapseStyle" @click= "clickCollapse()">
          <i :class=" isCollapse ? 'el-icon-d-arrow-right' : 'el-icon-d-arrow-left' "></i>
        </div>
        <!-- 一级菜单 -->
        <el-menu background-color="#545c64" text-color="#fff" :collapse-transition="false" :collapse="isCollapse" active-text-color="#ffd04b" unique-opened :router="true">
          <el-submenu :index="item.id + '' " v-for="item in menulist" :key='item.id'>
            <!-- 一级菜单模板 -->
            <template slot="title">
              <i :class="iconsobj[item.id]"></i>
              <span>{{ item.menuName}}</span>
            </template>
            <el-menu-item-group>
              <el-menu-item :default-active='defaultactive' :index='childrenitem.path' v-for="childrenitem in item.children" :key='childrenitem.id'>
                <!-- 二级菜单模板 -->
                <template slot="title">
                  <i class="el-icon-menu"></i>
                  <span>{{ childrenitem.menuName }}</span>
                </template>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-container>
        <!-- 内容区域 -->
        <el-main>
          <router-view></router-view>
        </el-main>
        <!-- 底部 -->
        <el-footer>Footer</el-footer>
      </el-container>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      defaultactive: this.$route.fullPath,
      isCollapse: false,
      menulist: [{
        'id': 1,
        'menuName': '用户管理',
        'children': [
          { 'id': 11, 'menuName': '用户列表', 'path': '/users' }
        ]
      },
      {
        'id': 2,
        'menuName': '权限管理',
        'children': [
          { 'id': 21, 'menuName': '角色列表', 'path': '/roles' },
          { 'id': 22, 'menuName': '权限列表', 'path': '/roots' }
        ]
      }
      ],
      iconsobj: {
        '1': 'el-icon-user-solid',
        '2': 'el-icon-lock'
      }
    }
  },
  methods: {
    clickCollapse() {
      this.isCollapse = !this.isCollapse
    }
  }
}

</script>

<style>
.HomeContainer {
  height: 100%;
  color: white;
}
.el-submenu__title {
    font-size: 14px;
    color: #303133;
    padding: 0 70px;
    cursor: pointer;
    -webkit-transition: border-color .3s,background-color .3s,color .3s;
    transition: border-color .3s,background-color .3s,color .3s;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}
.isCollapseStyle{
  background-color: #4A5064;
  line-height: 28px;
  color: white;
  text-align: center;
  cursor: pointer;
}
.el-header {
  /*background-color: #B3C0D1;*/
  background-color: #545c64;
  color: #333;
  text-align: center;
  line-height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 22px;
  font-family: "微软雅黑";
  color:#fff;
  padding-left: 15px;
}
.el-footer {
  background-color: #545c64;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  /*background-color: #D3DCE6;*/
  background-color: #545c64;
  color: #333;
  text-align: center;
  line-height: 200px;
}
.el-aside .el-menu{
    border-right: none;
  }

.el-main {
  background-color: #E9EEF3;
  color: #333;
  text-align: center;
  line-height: 160px;
}

body>.el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

</style>
